﻿if not Exists(Select * from sysobjects where name = 'NewsLetterEmailSent' and xtype='U')
Begin
	
	Create Table dbo.NewsLetterEmailSent
	(
		Id int identity(1,1) not null,
		OrderId int not null,
		SentStateId int not null,
		SentDate datetime not null,
		FaultReason varchar(4096) null,
		Email varchar(256),
		CampaignId int null,
		NewsLetterId int null,
		UserId int null,
	)

	alter table dbo.NewsLetterEmailSent add constraint PK_NewsLetterEmailSent_Id primary key (Id)
	
	create index IX_NewsLetterEmailSent_Email on NewsLetterEmailSent (email)

	create index IX_NewsLetterEmailSent_CampaignId on NewsLetterEmailSent (CampaignId)

	create index IX_NewsLetterEmailSent_NewsLetterId on NewsLetterEmailSent (NewsLetterId)

	create index IX_NewsLetterEmailSent_UserId on NewsLetterEmailSent (UserId)
End
Go